#include <adapter_pattern.h>
#include <iostream>

void AdvanceMediaPlayer::playMp4(string fileName)
{
    cout << "Do nothing : " << fileName << endl;
}

void AdvanceMediaPlayer::playVlc(string fileName)
{
    cout << "Do nothing : " << fileName << endl;
}

void VlcPlayer::playVlc(string fileName)
{
    cout << "Playing vlc file. Name : " << fileName << endl;
}

void Mp4Player::playMp4(string fileName)
{
    cout << "Playing mp4 file. Name : " << fileName << endl;
}

MediaAdapter::MediaAdapter(string audioType)
{
    if(audioType == "vlc")
    {
        advanceMediaPlayer = new VlcPlayer();
    } else if(audioType == "mp4") {
        advanceMediaPlayer = new Mp4Player();
    }
}

MediaAdapter::~MediaAdapter()
{
    delete advanceMediaPlayer;
}

void MediaAdapter::play(string audioType, string fileName)
{
    if(audioType == "vlc")
    {
        advanceMediaPlayer->playVlc(fileName);
    } else if(audioType == "mp4") {
        advanceMediaPlayer->playMp4(fileName);
    }
}

AudioPlayer::~AudioPlayer()
{
    delete mediaAdapter;
}

void AudioPlayer::play(string audioType, string fileName)
{
    if(audioType == "mp3")
    {
        cout << "Playing mp3 file. Name : " << fileName << endl;
    } else if(audioType == "vlc") {
        mediaAdapter = new MediaAdapter(audioType);
        mediaAdapter->play(audioType, fileName);
    } else if(audioType == "mp4"){
        mediaAdapter = new MediaAdapter(audioType);
        mediaAdapter->play(audioType, fileName);
    } else {
        cout << "invalid media. " << audioType << " format not supported" << endl;
    }
}

/*
    AudioPlayer* audioPlayer = new AudioPlayer();

    audioPlayer->play("mp3", "beyond the horizon.mp3");
    audioPlayer->play("mp4", "alone.mp4");
    audioPlayer->play("vlc", "far far away.vlc");
    audioPlayer->play("avi", "mind me.avi");
    */
